package com.whately.core.base.event;


import com.whately.core.base.exception.ServiceException;
import com.whately.core.base.logbackcfg.WhatelyLoggerBuilder;
import com.whately.core.base.model.RecorderModel;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 操作日志记录
 */
@Service
public class RecorderOperateBySlf4jImpl implements IRecorderOperate{

    @Autowired
    private WhatelyLoggerBuilder whatelyLoggerBuilder;



    @Override
    public int record(RecorderModel recorderModel) {
        getLogger().info("recorder info {}",recorderModel);
        return 1;
    }

    @Override
    public int getHandlerCode(){
        return 999;
    }

    @Override
    public int testQuery() throws ServiceException {
        return 1;
    }

    private Logger getLogger(){
        Logger logger = whatelyLoggerBuilder.fetchLogger(RecorderOperateBySlf4jImpl.class);
        return logger;
    }
}
